
class Variable:
    def __init__( self, name = None, type = None, value = None, isCMakeVar = False):
        self.hasChanged = False
        self.__name = name
        self.__type = type
        self.__value = value
        self.__isCMakeVar = isCMakeVar
        self.__formattedStr = ""

    def applyChanges( self):
        """ Used after applying changes by the user"""
        self.hasChanged = False

    def setName( self, name):
        self.__name = name

    def setType( self, type):
        self.__type = type

    def setAsCMakeVar( self):
        self.__isCMakeVar = True

    def isCMakeVar( self):
        return self.__isCMakeVar

    def setValue( self, value):
        self.__value = value
        self.hasChanged = True

    def getName( self):
        return self.__name

    def getType( self):
        return self.__type

    def getValue( self):
        return self.__value

    def getFormattedStr( self):
        if len( self.__formattedStr) == 0:
            self.__formatStr()

        return self.__formattedStr

    def __formatStr( self):
        if self.__isCMakeVar:
            self.__formattedStr = '-D' + self.__name + '=' + self.__value
        else:
            self.__formattedStr = '-D' + self.__name + ':' + self.__type + '=' + self.__value

